'use strict'

const readline = require('readline')
const fs = require('fs')
const AppHotel = require('./classes/AppHotel')

const rl = readline.createInterface({
  input: fs.createReadStream(process.argv[2])
})

rl.on('line', estadia => {
  const app = new AppHotel()
  app.registerHotels()

  const budgets = app.createBudgets(app.getHotels(), estadia)
  app.setBudgets(budgets)

  const hotel = app.searchHotelLowerPrice(app.getBudgets())

  console.log(hotel.name)
})
